package com.zuser.project.entity;

import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import java.io.Serializable;
import java.util.Date;

/**
 * 客户表
 * @author zuser
 */
@Data
@TableName("customer_info")
@Schema(description = "客户信息实体类")
public class CustomerInfoEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 主键
	 */
	@TableId(type = IdType.AUTO)
	@Schema(description = "主键ID", example = "1")
	private Long id;

	/**
	 * 微信openId（非空）
	 */
	@NotBlank(message = "微信openId不能为空")
	@Length(max = 64, message = "微信openId长度不能超过64个字符")
	@Schema(description = "微信openId", requiredMode = Schema.RequiredMode.REQUIRED, example = "o123456789abcdefg")
	private String wxOpenId;

	/**
	 * 客户昵称（非空，最大长度为32）
	 */
	@NotBlank(message = "客户昵称不能为空")
	@Length(max = 32, message = "客户昵称长度不能超过32个字符")
	@Schema(description = "客户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "小明")
	private String nickname;

	/**
	 * 性别（只能是"男"或"女"）
	 */
	@Schema(description = "性别", allowableValues = {"1", "2"}, example = "男")
	private String gender;

	/**
	 * 头像（URL格式校验，允许为空）
	 */
	@Pattern(regexp = "^$|(https?://.*)", message = "头像链接必须是有效的URL")
	@Schema(description = "头像链接", example = "https://example.com/avatar.jpg")
	private String avatarUrl;

	/**
	 * 电话（手机号格式校验，允许为空）
	 */
	@Pattern(regexp = "^$|^1[3-9]\\d{9}$", message = "电话号码格式不正确")
	@Schema(description = "电话号码", example = "13800138000")
	private String phone;

	/**
	 * 状态（1有效，2禁用，必须为1或2）
	 */
	@NotNull(message = "状态不能为空")
	@Min(value = 1, message = "状态值最小为1")
	@Max(value = 2, message = "状态值最大为2")
	@Schema(description = "状态", allowableValues = {"1", "2"}, example = "1")
	private Integer status;

	/**
	 * 创建时间
	 */
	@TableField(fill = FieldFill.INSERT)
//	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Schema(description = "创建时间", example = "2025-04-01 12:00:00")
	private Date createTime;

	/**
	 * 更新时间
	 */
	@TableField(fill = FieldFill.INSERT_UPDATE)
//	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
	@Schema(description = "更新时间", example = "2025-04-01 12:00:00")
	private Date updateTime;

	/**
	 * 删除标志（0未删除，1已删除）
	 */
	@NotNull(message = "删除标志不能为空")
	@Min(value = 0, message = "删除标志只能为0或1")
	@Max(value = 1, message = "删除标志只能为0或1")
	@Schema(description = "删除标志", allowableValues = {"0", "1"}, example = "0")
	private Integer isDeleted;
}